package com.goodving.guli.bt.ui;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewStub;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewSwitcher;

import com.goodving.guli.R;
import com.goodving.guli.activity.DynamicDetailActivity;
import com.goodving.guli.activity.WeightReportActivity;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.C0708b;
import com.goodving.guli.bt.C0715c;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.model.C1981P;
import com.goodving.guli.bt.model.DataManager;
import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.profile.scale.C3843c;
import com.goodving.guli.bt.profile.scale.ScaleWeightInfo;
import com.goodving.guli.bt.utils.C0893f;
import com.goodving.guli.bt.utils.WeightUtil;
import com.goodving.guli.bt.weight.UserInfo;
import com.goodving.guli.bt.weight.UserInfoManager;
import com.goodving.guli.bt.weight.family.WeightChooseUserActivity;
import com.goodving.guli.model.DeviceSource;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.utility.Constants;
import com.goodving.guli.view.BitmapDescriptorFactory;
import com.goodving.guli.view.C0804t;
import com.goodving.guli.view.C3247b;
import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;
import com.goodving.guli.view.PageIndicator;

import java.util.List;

import cn.com.smartdevices.bracelet.chart.DynamicPieChartView;
import cn.com.smartdevices.bracelet.chart.compat.Compat;
import cn.com.smartdevices.bracelet.chart.util.AnimUtil;
import cn.com.smartdevices.bracelet.chart.util.C0801q;
import cn.com.smartdevices.bracelet.chart.util.ChartData;

/**
 * Created by john on 2015/12/2.
 */
public class DynamicView extends FrameLayout implements ViewSwitcher.ViewFactory {
    private static final String f10527a = "Chart.DynamicView";
    private Animator mAnimator; // f10528A
    private ImageView f10529B;
    private ImageView f10530C;
    private ImageView f10531D;
    private ImageView f10532E;
    private int f10533F;
    private Boolean f10534G;
    private C1981P f10535H;
    private int f10536I;
    private PageIndicator f10537J;
    private ValueAnimator mValueAnimatorA; // f10538K
    private ValueAnimator mValueAnimatorB; // f10539L
    private ValueAnimator mValueAnimatorC; // f10540M
    private ValueAnimator mValueAnimatorD; // f10541N
    private ValueAnimator mValueAnimatorE; // f10542O
    private ValueAnimator mValueAnimatorF; // f10542P
    private final View f10544b;
    private final DynamicPieChartView mDynamicPieChartView; // f10545c
    private View mView; // f10546d
    private TextView f10547e;
    private TextView f10548f;
    private TextView f10549g;
    private TextView f10550h;
    private TextView f10551i;
    private TextView f10552j;
    private TextView f10553k;
    private TextView f10554l;
    private TextView f10555m;
    private TextView f10556n;
    private TextView f10557o;
    private TextView f10558p;
    private TextView f10559q;
    private TextView f10560r;
    private TextView f10561s;
    private TextView f10562t;
    private View f10563u;
    private View f10564v;
    private float f10565w;
    private float f10566x;
    private int f10567y;
    private int f10568z;

    public class FlowBgView extends View {
        private final Paint f10522a;
        private float f10523b;
        private float f10524c;
        private float f10525d;
        private float f10526e;

        public FlowBgView(Context context) {
            this(context, null, 0);
        }

        public FlowBgView(Context context, AttributeSet attributeSet) {
            this(context, attributeSet, 0);
        }

        public FlowBgView(Context context, AttributeSet attributeSet, int i) {
            super(context, attributeSet, i);
            this.f10522a = new Paint();
            this.f10522a.setColor(0xFF2980B9);
        }

        class C1921q implements ValueAnimator.AnimatorUpdateListener {
            final /* synthetic */ FlowBgView f10886a;

            C1921q(FlowBgView flowBgView) {
                this.f10886a = flowBgView;
            }

            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                this.f10886a.f10526e = (float) ((int) (((((Float) valueAnimator.getAnimatedValue()).floatValue() * (1.0f - 0.19482619f)) + 0.19482619f) * this.f10886a.f10523b));
                Compat.postOnAnimationInvalidate(this.f10886a);
            }
        }

        public Animator m15085a() {
            return AnimUtil.m8744a(new C1921q(this));
        }

        protected void onDraw(Canvas canvas) {
            canvas.drawCircle(this.f10524c, this.f10525d, this.f10526e, this.f10522a);
        }

        protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
            super.onLayout(z, i, i2, i3, i4);
            int i5 = i3 - i;
            int i6 = i4 - i2;
            this.f10523b = (float) i6;
            this.f10526e = this.f10523b;
            this.f10524c = ((float) i5) / 2.0f;
            this.f10525d = ((float) i6) * 0.42037186f;
        }
    }

    public DynamicView(Context context) {
        this(context, null, 0);
    }

    public DynamicView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public DynamicView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f10534G = Boolean.valueOf(false);
        this.f10536I = 0;
        this.mValueAnimatorA = null;
        this.mValueAnimatorB = null;
        this.mValueAnimatorC = null;
        this.mValueAnimatorD = null;
        this.mValueAnimatorE = null;
        this.mValueAnimatorF = null;
        inflate(context, R.layout.view_dynamic, this);
        this.f10536I = (int) Utils.m8026b(106.0f, context);
        this.f10544b = findViewById(R.id.center_host);
        this.mDynamicPieChartView = (DynamicPieChartView) findViewById(R.id.active_step_chart);
        this.f10534G = Keeper.readIsPlayEnterAnimation();
        if (this.f10534G.booleanValue()) {
        }
        if (C0804t.m8835a()) {
            int a = (int) C0804t.m8825a(getContext(), 265.0f);
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) this.f10544b.getLayoutParams();
            marginLayoutParams.width = a;
            marginLayoutParams.height = a;
            marginLayoutParams.topMargin = (int) C0804t.m8825a(getContext(), 70.0f);
            this.f10544b.setLayoutParams(marginLayoutParams);
        }
    }

    private void m15087a(Context context) {
        GuliLog.tracePrintInfo(f10527a, "click mWeightContainer");
        if (this.f10535H == null || this.f10535H.weightInfo == null) {
            GuliLog.tracePrintInfo(f10527a, "data or advData is null");
        } else {
            GuliLog.tracePrintInfo(f10527a, "data.advData " + this.f10535H.weightInfo.toString() + " timestamp " + this.f10535H.weightInfo.m25494e());
        }
        if (this.f10535H == null) {
            return;
        }
        if (this.f10535H.f11137e) {
            C3247b.m22928a(context, (int) R.string.weight_no_tips, 0).show();
        } else if (!this.f10535H.weightInfo.isStable()) {
        } else {
            if (this.f10535H.f11135c == 0) {
                m15089a(context, this.f10535H.weightInfo, this.f10535H.userInfoList);
                return;
            }
            GuliLog.tracePrintInfo(f10527a, this.f10535H.f11135c + " " + this.f10535H.weightInfo);
            Intent intent = new Intent(context, WeightReportActivity.class);
            intent.putExtra(UserInfo.USERINFO_KEY, UserInfoManager.getInstance().getInfoByUid(this.f10535H.f11135c) == null ?
                    C3657a.f18328f : UserInfoManager.getInstance().getInfoByUid(this.f10535H.f11135c).toJsonString());
            intent.putExtra(ScaleWeightInfo.WEIGHTADVDATA_KEY, this.f10535H.weightInfo.m25503n());
            context.startActivity(intent);
            C0668a.m8128a(context, C0668a.fB, C0668a.fC);
        }
    }

    private void m15088a(Context context, int i) {
        Intent intent = new Intent(context, DynamicDetailActivity.class);
        intent.putExtra(ChartData.KEY_MODE, i);
        //if (!DeviceSource.hasBindPeripheralDevice() && Utils.m8088m(getContext())) {
        if (!DeviceSource.hasBindPeripheralDevice() && Utils.m8088m(getContext())) {
            intent.putExtra(ChartData.KEY_SOURCE, C3843c.SENSORHUB.m25103b());
        }
        context.startActivity(intent);
    }

    private void m15089a(Context context, ScaleWeightInfo c3925e, List<UserInfo> list) {
        if (Utils.m8055c((Activity) context)) {
            int[] iArr = new int[list.size()];
            for (int i = 0; i < list.size(); i++) {
                iArr[i] = ((UserInfo) list.get(i)).uid;
            }
            Intent intent = new Intent(context, WeightChooseUserActivity.class);
            intent.putExtra(ScaleWeightInfo.WEIGHTADVDATA_KEY, c3925e.m25503n());
            intent.putExtra("USER_LIST", iArr);
            context.startActivity(intent);
            C0668a.m8126a(context, C0668a.fQ);
        }
    }

    private void m15090a(View view) {
        this.f10547e = (TextView) view.findViewById(R.id.step);
        this.f10548f = (TextView) view.findViewById(R.id.step_distance);
        this.f10549g = (TextView) view.findViewById(R.id.step_calorie);
        this.f10550h = (TextView) view.findViewById(R.id.step_tip);
        this.f10551i = (TextView) view.findViewById(R.id.step_unit);
        this.f10552j = (TextView) view.findViewById(R.id.shoes_distance);
        this.f10564v = view.findViewById(R.id.shoes_distance_view);
        this.f10532E = (ImageView) view.findViewById(R.id.lining_logo_top);
        if (DeviceSource.hasBindBracelet() || !DeviceSource.hasBindShoesDevice()) {
            this.f10532E.setVisibility(View.INVISIBLE);
        } else {
            this.f10532E.setVisibility(View.VISIBLE);
        }
        if (C0804t.m8835a()) {
            this.f10547e.setTextSize(43.0f);
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) this.f10550h.getLayoutParams();
            marginLayoutParams.topMargin = (int) C0804t.m8825a(getContext(), 45.0f);
            this.f10550h.setTextSize((float) 11);
            this.f10550h.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) ((View) this.f10548f.getParent()).getLayoutParams();
            marginLayoutParams.bottomMargin = (int) C0804t.m8825a(getContext(), 45.0f);
            this.f10548f.setTextSize((float) 11);
            this.f10549g.setTextSize((float) 11);
            ((View) this.f10548f.getParent()).setLayoutParams(marginLayoutParams);
        }
    }

    private void m15094b(View view) {
        this.f10553k = (TextView) view.findViewById(R.id.sleep_hour);
        this.f10554l = (TextView) view.findViewById(R.id.sleep_hour_unit);
        this.f10555m = (TextView) view.findViewById(R.id.sleep_min);
        this.f10556n = (TextView) view.findViewById(R.id.sleep_min_unit);
        this.f10557o = (TextView) view.findViewById(R.id.sleep_deep_time);
        this.f10558p = (TextView) view.findViewById(R.id.sleep_tip);
        if (C0804t.m8835a()) {
            this.f10553k.setTextSize(32.0f);
            this.f10554l.setTextSize(24.5f);
            this.f10555m.setTextSize(32.0f);
            this.f10556n.setTextSize(24.5f);
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) this.f10558p.getLayoutParams();
            marginLayoutParams.topMargin = (int) C0804t.m8825a(getContext(), 45.0f);
            this.f10558p.setTextSize((float) 11);
            this.f10558p.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) this.f10557o.getLayoutParams();
            marginLayoutParams.bottomMargin = (int) C0804t.m8825a(getContext(), 45.0f);
            this.f10557o.setTextSize((float) 11);
            this.f10557o.setLayoutParams(marginLayoutParams);
        }
    }

    private void m15096c(View view) {
        this.f10559q = (TextView) view.findViewById(R.id.weight);
        this.f10560r = (TextView) view.findViewById(R.id.weight_unit);
        this.f10561s = (TextView) view.findViewById(R.id.weight_bmi);
        this.f10562t = (TextView) view.findViewById(R.id.weight_tip);
        if (C0804t.m8835a()) {
            this.f10559q.setTextSize(43.0f);
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) this.f10562t.getLayoutParams();
            marginLayoutParams.topMargin = (int) C0804t.m8825a(getContext(), 140.0f);
            this.f10562t.setTextSize(16.0f);
            this.f10562t.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) this.f10561s.getLayoutParams();
            marginLayoutParams.bottomMargin = (int) C0804t.m8825a(getContext(), 45.0f);
            this.f10561s.setTextSize((float) 11);
            this.f10561s.setLayoutParams(marginLayoutParams);
        }
    }

    class C1915k implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ DynamicView f10880a;

        C1915k(DynamicView dynamicView) {
            this.f10880a = dynamicView;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f10880a.mView.setAlpha(floatValue / 100.0f);
            ((View) this.f10880a.f10537J).setAlpha(floatValue / 100.0f);
        }
    }

    private void m15098d() {
        this.mValueAnimatorA = ValueAnimator.ofFloat(new float[]{0.0f, 100.0f});
        this.mValueAnimatorA.setDuration(800);
        this.mValueAnimatorA.setInterpolator(new DecelerateInterpolator(3.0f));
        this.mValueAnimatorA.addUpdateListener(new C1915k(this));
        this.mValueAnimatorA.start();
    }

    class C1916l implements Animator.AnimatorListener {
        final /* synthetic */ DynamicView f10881a;

        C1916l(DynamicView dynamicView) {
            this.f10881a = dynamicView;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f10881a.mDynamicPieChartView.setScaleX(1.0f);
            this.f10881a.mDynamicPieChartView.setScaleY(1.0f);
        }
    }

    class C1917m implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ DynamicView f10882a;

        C1917m(DynamicView dynamicView) {
            this.f10882a = dynamicView;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f10882a.mDynamicPieChartView.setScaleX(floatValue);
            this.f10882a.mDynamicPieChartView.setScaleY(floatValue);
        }
    }


    private void m15100e() {
        if (this.mValueAnimatorB == null || !this.mValueAnimatorB.isRunning()) {
            this.mValueAnimatorB = ValueAnimator.ofFloat(new float[]{1.0f, 1.03f, 1.07f, 1.1f, 1.1f, 1.07f, 1.03f, 1.0f, 0.95f, 0.9f, 0.95f, 1.0f, 1.05f, 1.0f});
            this.mValueAnimatorB.setDuration(1000);
            this.mValueAnimatorB.setInterpolator(new DecelerateInterpolator());
            this.mValueAnimatorB.addListener(new C1916l(this));
            this.mValueAnimatorB.addUpdateListener(new C1917m(this));
            this.mValueAnimatorB.start();
        }
    }

    class C1918n implements Animator.AnimatorListener {
        final /* synthetic */ DynamicView f10883a;

        C1918n(DynamicView dynamicView) {
            this.f10883a = dynamicView;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f10883a.mDynamicPieChartView.setRotationY(0.0f);
        }
    }

    class C1919o implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ DynamicView f10884a;

        C1919o(DynamicView dynamicView) {
            this.f10884a = dynamicView;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            this.f10884a.mDynamicPieChartView.setRotationY(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }
    }

    private void m15101f() {
        this.mValueAnimatorC = ValueAnimator.ofFloat(new float[]{0.0f, 10.0f, 0.0f});
        this.mValueAnimatorC.setDuration(500);
        this.mValueAnimatorC.setInterpolator(new DecelerateInterpolator());
        this.mValueAnimatorC.addListener(new C1918n(this));
        this.mValueAnimatorC.addUpdateListener(new C1919o(this));
        this.mValueAnimatorC.start();
    }

    class C1920p implements Animator.AnimatorListener {
        final /* synthetic */ DynamicView f10885a;

        C1920p(DynamicView dynamicView) {
            this.f10885a = dynamicView;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f10885a.m15101f();
            this.f10885a.m15098d();
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f10885a.f10544b.setRotationY(-90.0f);
            this.f10885a.f10544b.setTranslationY(BitmapDescriptorFactory.HUE_MAGENTA);
            this.f10885a.f10544b.setAlpha(0.0f);
        }
    }

    class C1908d implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ DynamicView f10873a;

        C1908d(DynamicView dynamicView) {
            this.f10873a = dynamicView;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f10873a.f10544b.setRotationY(-90.0f + ((90.0f * floatValue) / 100.0f));
            this.f10873a.f10544b.setTranslationY(BitmapDescriptorFactory.HUE_MAGENTA - ((BitmapDescriptorFactory.HUE_MAGENTA * floatValue) / 100.0f));
            if (floatValue < 50.0f) {
                this.f10873a.f10544b.setAlpha((floatValue * 0.5f) / 100.0f);
                return;
            }
            this.f10873a.f10544b.setAlpha(floatValue / 100.0f);
        }
    }


    private void m15103g() {
        if (this.mValueAnimatorC != null) {
            this.mValueAnimatorC.end();
        }
        if (this.mValueAnimatorA != null) {
            this.mValueAnimatorA.end();
        }
        this.mValueAnimatorD = ValueAnimator.ofFloat(new float[]{0.0f, 100.0f});
        this.mValueAnimatorD.setDuration(800);
        this.mValueAnimatorD.setInterpolator(new LinearInterpolator());
        this.mValueAnimatorD.addListener(new C1920p(this));
        this.mValueAnimatorD.addUpdateListener(new C1908d(this));
        this.mValueAnimatorD.start();
    }

    private Animator m15105h(int i) {
        C0801q.m8765a(this.mDynamicPieChartView.animRefresh());
        if (i == 1) {
            C0801q.m8769b(AnimUtil.m8740a(this.f10567y, this.f10568z, this.f10547e));
        } else if (i == PersonInfo.INCOMING_CALL_DISABLE_BIT && this.f10565w == -1 && this.f10566x > -1) {
            Animator a = AnimUtil.m8739a(0.0f, this.f10566x, 1, this.f10559q);
            a.setDuration(this.mDynamicPieChartView.m8405l() / 2);
            C0801q.m8769b(a);
        }
        return C0801q.m8764a();
    }

    class C1909e implements Animator.AnimatorListener {
        final /* synthetic */ DynamicView f10874a;

        C1909e(DynamicView dynamicView) {
            this.f10874a = dynamicView;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f10874a.f10529B.setAlpha(0.0f);
            this.f10874a.f10530C.setAlpha(0.0f);
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f10874a.f10529B.setVisibility(View.VISIBLE);
            this.f10874a.f10530C.setVisibility(View.VISIBLE);
            this.f10874a.f10544b.setRotationY(-90.0f);
            this.f10874a.f10544b.setTranslationY(BitmapDescriptorFactory.HUE_MAGENTA);
            this.f10874a.f10544b.setAlpha(0.0f);
            this.f10874a.f10529B.setAlpha(1.0f);
            this.f10874a.f10529B.setTranslationX(0.0f);
            this.f10874a.f10529B.setTranslationY(0.0f);
            this.f10874a.f10529B.setScaleX(1.0f);
            this.f10874a.f10529B.setScaleY(1.0f);
            this.f10874a.f10530C.setAlpha(1.0f);
            this.f10874a.f10530C.setTranslationX(0.0f);
            this.f10874a.f10530C.setTranslationY(0.0f);
            this.f10874a.f10530C.setScaleX(1.0f);
            this.f10874a.f10530C.setScaleY(1.0f);
            ((View) this.f10874a.f10537J).setAlpha(0.0f);
            this.f10874a.m15103g();
        }
    }

    class C1910f implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ DynamicView f10875a;

        C1910f(DynamicView dynamicView) {
            this.f10875a = dynamicView;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f10875a.f10529B.setTranslationX((C4220a.bP * floatValue) / 100.0f);
            this.f10875a.f10529B.setTranslationY((-200.0f * floatValue) / 100.0f);
            this.f10875a.f10529B.setScaleX(1.0f - ((0.7f * floatValue) / 100.0f));
            this.f10875a.f10529B.setScaleY(1.0f - ((0.2f * floatValue) / 100.0f));
            if (floatValue <= 50.0f) {
                this.f10875a.f10529B.setAlpha(1.0f - ((1.0f * floatValue) / 50.0f));
                this.f10875a.f10530C.setAlpha(1.0f - ((1.0f * floatValue) / 50.0f));
            }
            this.f10875a.f10530C.setTranslationX((450.0f * floatValue) / 100.0f);
            this.f10875a.f10530C.setTranslationY((floatValue * C4220a.bP) / 100.0f);
        }
    }

    private void m15107h() {
        if (this.mValueAnimatorD != null) {
            this.mValueAnimatorD.end();
        }
        if (this.mValueAnimatorC != null) {
            this.mValueAnimatorC.end();
        }
        if (this.mValueAnimatorA != null) {
            this.mValueAnimatorA.end();
        }
        this.mValueAnimatorE = ValueAnimator.ofFloat(new float[]{0.0f, 100.0f});
        this.mValueAnimatorE.setDuration(600);
        this.mValueAnimatorE.setInterpolator(new LinearInterpolator());
        this.mValueAnimatorE.addListener(new C1909e(this));
        this.mValueAnimatorE.addUpdateListener(new C1910f(this));
        this.mValueAnimatorE.start();
    }

    class C1911g implements Animator.AnimatorListener {
        final /* synthetic */ DynamicView f10876a;

        C1911g(DynamicView dynamicView) {
            this.f10876a = dynamicView;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f10876a.m15101f();
            this.f10876a.m15098d();
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f10876a.f10544b.setRotationY(-180.0f);
            this.f10876a.f10544b.setAlpha(0.0f);
            this.f10876a.f10544b.setTranslationY(C4220a.bP);
            this.f10876a.f10531D.setTranslationY(C4220a.bP);
        }
    }

    class C1912h implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ DynamicView f10877a;

        C1912h(DynamicView dynamicView) {
            this.f10877a = dynamicView;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue() / 600.0f;
            this.f10877a.f10531D.setRotationY(BitmapDescriptorFactory.HUE_CYAN * floatValue);
            this.f10877a.f10544b.setRotationY(-180.0f + (BitmapDescriptorFactory.HUE_CYAN * floatValue));
            this.f10877a.f10544b.setAlpha(floatValue);
            float f = 1.0f - (2.0f * floatValue);
            if (f < 0.0f) {
                f = 0.0f;
            }
            this.f10877a.f10531D.setAlpha(f);
            this.f10877a.f10544b.setTranslationY((1.0f - floatValue) * C4220a.bP);
            this.f10877a.f10531D.setTranslationY((1.0f - floatValue) * C4220a.bP);
        }
    }


    private void m15109i() {
        if (this.mValueAnimatorC != null) {
            this.mValueAnimatorC.end();
        }
        if (this.mValueAnimatorA != null) {
            this.mValueAnimatorA.end();
        }
        this.mValueAnimatorF = ValueAnimator.ofFloat(new float[]{0.0f, 600.0f});
        this.mValueAnimatorF.setDuration(800);
        this.mValueAnimatorF.setInterpolator(new LinearInterpolator());
        this.mValueAnimatorF.addListener(new C1911g(this));
        this.mValueAnimatorF.addUpdateListener(new C1912h(this));
        this.mValueAnimatorF.start();
    }

    public void m15112a() {
        m15133c(false);
    }

    public void m15113a(float f) {
        if (f >= 0.0f && f <= 1.0f) {
            this.mDynamicPieChartView.setRotationX(90.0f - (f * 90.0f));
            this.mDynamicPieChartView.setAlpha(f);
            this.f10544b.setTranslationY(((float) (-this.f10536I)) * (1.0f - f));
            if (this.f10537J != null) {
                if (((double) f) > 0.93d && f <= 1.0f) {
                    ((View) this.f10537J).setTranslationY(0.0f);
                    ((View) this.f10537J).setAlpha(1.0f - ((1.0f - f) / 0.07f));
                } else if (f < 0.0f || ((double) f) >= 0.07d) {
                    ((View) this.f10537J).setTranslationY(0.0f);
                    ((View) this.f10537J).setAlpha(0.0f);
                } else {
                    ((View) this.f10537J).setTranslationY(-(((float) this.f10536I) + C0804t.m8825a(getContext(), 115.0f)));
                    ((View) this.f10537J).setAlpha(1.0f - (f / 0.07f));
                }
            }
            if (this.f10550h != null) {
                this.f10550h.setAlpha(f);
                ((View) this.f10548f.getParent()).setAlpha(f);
                this.f10551i.setAlpha(1.0f - f);
            }
            if (this.f10558p != null) {
                this.f10558p.setAlpha(f);
                this.f10557o.setAlpha(f);
            }
            if (this.f10562t != null) {
                this.f10562t.setAlpha(f);
                this.f10561s.setAlpha(f);
            }
            if (this.f10532E != null) {
                this.f10532E.setAlpha(f);
            }
            if (this.f10564v != null) {
                this.f10564v.setAlpha(f);
            }
        }
    }

    public void m15114a(float f, float f2, float f3) {
        if (f == ScaleWeightInfo.f19751c) {
            this.f10559q.setText("OL");
            this.f10565w = 0.0f;
            this.f10566x = -1;
        } else {
            // TBD DEBUG
            this.f10565w = this.f10566x;
            this.f10566x = f;
//            Log.e("Chart.DynamicView", GuliLog.stackTracePrint() + String.valueOf(WeightUtil.m15715c(f)));

            this.f10559q.setText(String.valueOf(WeightUtil.m15715c(f)));
            if (this.f10535H == null || !this.f10535H.f11137e) {
                this.f10559q.setAlpha(1.0f);
            } else {
                this.f10559q.setAlpha(0.6f);
            }
        }
        // to set the shape icon for the weight
        this.mDynamicPieChartView.m8442a(150.0f);
        this.mDynamicPieChartView.m8449d(f3);
        this.mDynamicPieChartView.m8447c(f2);

    }


    public void m15114a(float f, float f2, float f3, float f4) {
        int scaleIcon = 0;
        if (f == ScaleWeightInfo.f19751c) {
            this.f10559q.setText("OL");
            this.f10565w = 0.0f;
            this.f10566x = -1;
        } else {
            // TBD DEBUG
            this.f10565w = this.f10566x;
            this.f10566x = f;
//            Log.e("Chart.DynamicView", GuliLog.stackTracePrint() + String.valueOf(WeightUtil.m15715c(f)));

            this.f10559q.setText(String.valueOf(WeightUtil.m15715c(f)));
            if (this.f10535H == null || !this.f10535H.f11137e) {
                this.f10559q.setAlpha(1.0f);
            } else {
                this.f10559q.setAlpha(0.6f);
            }
        }
        // to set the shape icon for the weight
        if(f4 >= 36) {
            scaleIcon = R.drawable.male_fatest;
        } else if (f4 >= 32 && f4 < 36 ) {
            scaleIcon = R.drawable.male_fatbig;
        } else if (f4 >= 28 && f4 < 32 ) {
            scaleIcon = R.drawable.male_fatmiddle;
        } else if (f4 >= 24 && f4 < 28 ) {
            scaleIcon = R.drawable.male_fatlitter;
        } else if (f4 >= 22 && f4 < 24 ) {
            scaleIcon = R.drawable.male_fatter;
        } else if (f4 >= 16 && f4 < 22 ) {
            scaleIcon = R.drawable.male_adult;
        } else if (f4 >= 1 && f4 < 16 ){
            scaleIcon = R.drawable.icon_thin;
        } else {
            scaleIcon = R.drawable.ic_dynamic_weight;
        }

        if (f3 == 0) {
            scaleIcon = R.drawable.ic_dynamic_weight;
        }
        // set icon;
        this.mDynamicPieChartView.setScaleIcon(scaleIcon);
        this.mDynamicPieChartView.m8442a(150.0f);
        this.mDynamicPieChartView.m8449d(f3);
        this.mDynamicPieChartView.m8447c(f2);

    }

    public void m15115a(float f, int i, int i2) {
        if (f <= 0.0f) {
            this.f10561s.setText("BMI " + WeightUtil.m15709b(f));
        } else {
            this.f10561s.setText("BMI " + WeightUtil.m15709b(f) + " " + WeightUtil.m15697a(getContext(), f, i, i2));
        }
    }

    public void m15116a(int i) {
        this.mDynamicPieChartView.m8442a((float) i);
    }

    public void m15117a(long j) {
        if (this.mAnimator != null) {
            AnimUtil.m8753a((View) this, (AnimatorSet) this.mAnimator, j);
        }
    }

    public void m15118a(PageIndicator c1858c) {
        this.f10537J = c1858c;
    }

    public void m15119a(C1981P c1981p) {
        this.f10535H = c1981p;
    }

    public void m15120a(Boolean bool) {
        if (this.f10544b != null) {
            if (bool.booleanValue()) {
                this.f10544b.setAlpha(0.3f);
                return;
            }
            this.f10544b.setAlpha(1.0f);
            m15100e();
        }
    }

    public void m15121a(String str) {
        this.f10550h.setText(str);
    }

    public void m15122a(boolean z) {
        if (this.f10533F == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
//            if (this.f10563u == null) {
//                this.f10563u = ((ViewStub) this.mView.findViewById(R.id.info_weight_low_battery)).inflate();
//            }
            if (z) {
                this.mView.findViewById(R.id.weight_container).setVisibility(View.INVISIBLE);
//                this.f10563u.setVisibility(View.VISIBLE);
                return;
            }
            this.mView.findViewById(R.id.weight_container).setVisibility(View.VISIBLE);
//            this.f10563u.setVisibility(View.GONE);
        }
    }

    public void m15123a(String[] strArr) {
        this.f10548f.setText(strArr[0] + strArr[1]);
    }

    public long m15124b() {
        return AnimUtil.m8738a((AnimatorSet) this.mAnimator);
    }

    public void m15125b(float f) {
        this.f10565w = f;
    }

    public void m15126b(int i) {
        this.f10568z = i;
        this.mDynamicPieChartView.m8447c((float) i);
    }

    public void m15127b(String str) {
        this.f10558p.setText(str);
    }

    public void m15128b(boolean z) {
        if (!z) {
            m15133c(false);
        }
    }

    public void m15129b(String[] strArr) {
        this.f10552j.setText(strArr[0] + strArr[1]);
    }

    public DynamicPieChartView m15130c() {
        return this.mDynamicPieChartView;
    }

    public void m15131c(int i) {
        if (this.f10564v != null) {
            this.f10564v.setVisibility(i);
        }
    }

    public void m15132c(String str) {
        this.f10560r.setText(str);
    }

    public void m15133c(boolean z) {
        if (this.mAnimator != null && this.mAnimator.isStarted()) {
            this.mAnimator.end();
        }
        if (z) {
            this.mAnimator = m15105h(this.f10533F);
            this.mAnimator.start();
            return;
        }
        if (this.f10533F == 1) {
            this.f10547e.setText(AnimUtil.m8759b(this.f10568z));
            this.f10551i.setText(R.string.unit_step);
        } else if (this.f10533F == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
            this.f10559q.setText(String.valueOf(WeightUtil.m15715c(this.f10566x)));
        }
        this.mDynamicPieChartView.refresh(false);
    }

    public void m15134d(int i) {
        this.f10549g.setText(String.valueOf(i) + getContext().getString(R.string.unit_calorie));
    }

    public void m15135d(String str) {
        this.f10562t.setText(str);
    }

    public void m15136e(int i) {
        String[] d = C0893f.m9094d(i);
        this.f10553k.setText(d[0]);
        this.f10554l.setText(R.string.unit_hour);
        this.f10555m.setText(d[1]);
        this.f10556n.setText(R.string.unit_min_short);
    }

    public void m15137f(int i) {
        this.f10557o.setText(getContext().getString(R.string.dynamic_sleep_deep_title, new Object[]{C0893f.m9090b(getContext(), i)}));
    }

    class C1914j implements OnClickListener {
        final /* synthetic */ DynamicView dynamicView; // f10879a

        C1914j(DynamicView dynamicView) {
            this.dynamicView = dynamicView;
        }

        public void onClick(View view) {
            this.dynamicView.m15087a(this.dynamicView.getContext());
        }
    }

    class C1907c implements OnClickListener {
        final /* synthetic */ DynamicView dynamicView; // f10872a

        C1907c(DynamicView dynamicView) {
            this.dynamicView = dynamicView;
        }

        public void onClick(View view) {
            if (DataManager.m12179a().m12239r() == 3) {
                C0668a.m8129a(this.dynamicView.getContext(), C0708b.bE, C0715c.f3778t, Constants.VIA_RESULT_SUCCESS);
            }
            this.dynamicView.m15088a(this.dynamicView.getContext(), this.dynamicView.f10533F);
        }
    }

    class C1913i implements OnClickListener {
        final /* synthetic */ DynamicView dynamicView; // f10878a

        C1913i(DynamicView dynamicView) {
            this.dynamicView = dynamicView;
        }

        public void onClick(View view) {
            this.dynamicView.m15088a(this.dynamicView.getContext(), this.dynamicView.f10533F);
        }
    }

    public void m15138g(int i) {
        this.f10533F = i;
        switch (i) {
            case 1 /*1*/:
                this.mView = ((ViewStub) findViewById(R.id.info_step)).inflate();
                this.mView.setOnClickListener(new C1907c(this));
                m15090a(this.mView);
                break;
            case 16 /*16*/:
                this.mView = ((ViewStub) findViewById(R.id.info_sleep)).inflate();
                this.mView.setOnClickListener(new C1913i(this));
                m15094b(this.mView);
                break;
            case PersonInfo.INCOMING_CALL_DISABLE_BIT /*256*/:
                this.mView = ((ViewStub) findViewById(R.id.info_weight)).inflate();
                this.mView.setOnClickListener(new C1914j(this));
                m15096c(this.mView);
                break;
        }
        this.mDynamicPieChartView.m8443a(i);
    }

    public View makeView() {
        return inflate(getContext(), R.layout.view_dynamic_textswitcher, null);
    }

    protected void onAttachedToWindow() {
        boolean z = true;
        super.onAttachedToWindow();
        m15128b(false);
        if (this.f10534G.booleanValue()) {
        }
        if (DeviceSource.hasBindDevice()) {
            z = false;
        }
        m15120a(Boolean.valueOf(z));
    }
}
